﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FortuneHeaven.Admin.Common;
using FortuneHeavenCommon.ComMethod;

namespace FortuneHeaven.Admin
{
    public partial class ChangePassword  : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AuthorityCenter.CheckLogin();
        }

        public void ModifyPwd(object sender, EventArgs e)
        {
            string oldpassword = this.TB_OldPassword.Text.Trim();
            string password = this.TTB_Password.Text.Trim();
            string dbpwd = this.TTB_DBPWD.Text.Trim();
            string validate = this.NTB_ValidateCode.Text.Trim();
            string error = "";
            if (AuthorityCenter.CheckAndChangePassword(oldpassword, password, dbpwd, validate, ref error))
            {
                Response.Redirect(ResolveUrl("~/Common/Frame/Default.aspx"));
            }
            else
            {
                ShowCurError(error);
            }

        }

        protected void ShowCurError(string message)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "error", string.Format("alert('{0}')", message), true);
        }
        public void ReturnPrev(object sender, EventArgs e)
        {
            Response.Redirect(ResolveUrl("~/Common/Frame/Default.aspx"));
        }
    }
}